import CryptoJS from "crypto-js";

export default {
  //加密
  encrypt(word, keyStr) {
    if (keyStr) {
      let iv = CryptoJS.enc.Utf8.parse(keyStr);
      let key = CryptoJS.enc.Utf8.parse(keyStr);
      let srcs = CryptoJS.enc.Utf8.parse(word);
      var encrypted = CryptoJS.AES.encrypt(srcs, key, {
        iv: iv,
        mode: CryptoJS.mode.CBC,
        padding: CryptoJS.pad.Pkcs7,
      });
      return encrypted.toString();
    }
  },
};
